package com.wan37.logic.tradingshop.service.impl;

import com.wan37.logic.tradingshop.dao.TradingShopDao;
import com.wan37.logic.tradingshop.domain.entity.TradingShopDO;
import com.wan37.logic.tradingshop.domain.vo.TradingShopVO;
import com.wan37.logic.tradingshop.service.TradingShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @author : luoyong
 * @date : 2020-08-05 16:06
 **/
@Component("tradingShopService")
public class TradingShopServiceImpl implements TradingShopService {
    @Autowired
    private TradingShopDao tradingShopDao;
    @Override
    public List<TradingShopVO> getAll() {
        List<TradingShopDO> tradingShopDOList = tradingShopDao.getAll();
        List<TradingShopVO> tradingShopVOList = null;
        if (tradingShopDOList != null){
            tradingShopVOList = new ArrayList<>();
            for (TradingShopDO tradingShopDO : tradingShopDOList){
                TradingShopVO tradingShopVO = new TradingShopVO(tradingShopDO);
                tradingShopVOList.add(tradingShopVO);
            }
        }
        return tradingShopVOList;
    }

    @Override
    public boolean deleteByTradingShopId(String tradingShopId) {
        return tradingShopDao.deleteByTradingShopId(tradingShopId);
    }


    @Override
    public boolean update(TradingShopVO tradingShopVO) {
        return false;
    }

    @Override
    public boolean save(TradingShopVO tradingShopVO) {
        return tradingShopDao.add(new TradingShopDO(tradingShopVO));
    }

    @Override
    public boolean delete(TradingShopVO tradingShopVO) {
        return false;
    }
}
